const CryptoJS = require('crypto-js') //引用AES源码js
var shopID = '合同号'
var posNO = 'POS机号'
var outTradeNo = '流水号'
var disMoney = '优惠金额'
var money = '交易金额'
var createTime = '交易时间'
var payCode = '支付方式代码'
var encodeContent =
  shopID +
  ',' +
  posNO +
  ',' +
  disMoney +
  ',' +
  money +
  ',' +
  createTime +
  ',' +
  outTradeNo +
  ',' +
  payCode
var highlinkKey = '6D4267DF81D83449D851617E|78549912'
var keys = highlinkKey.split('|')

// var enCode =
//   'iFpJBQY406scFoqMCBvXamNDJEV15RMe9/D/QW4NTgtFZnLH4zYYXX2sU+kcHAlzPeKHUIFN1A6OD6pydDQHTg=='

export default function getInfo(enCode) {
  var sign1 = CryptoJS.TripleDES.decrypt(
    enCode,
    CryptoJS.enc.Utf8.parse(keys[0]),
    {
      mode: CryptoJS.mode.CBC,
      padding: CryptoJS.pad.Pkcs7,
      iv: CryptoJS.enc.Utf8.parse(keys[1])
    }
  ).toString(CryptoJS.enc.Utf8)

  var values = sign1.split(',')
  var title = encodeContent.split(',')
  let obj = {}
  values.forEach((item, index, array) => {
    obj[title[index]] = item
  })
  // console.log(obj)

  return obj
}
